#define _CRT_SECURE_NO_WARNINGS 1

class TextEditor {
public:
    TextEditor() {

    }

    void addText(string text) {
        _left += text;
    }

    int deleteText(int k) {
        int del = k;
        del = min(del, (int)_left.size());
        _left.resize(_left.size() - del);
        return del;
    }

    string cursorLeft(int k) {
        int cur = max(0, (int)_left.size() - k);
        string past = _left.substr(cur);
        reverse(past.begin(), past.end());
        _right += past;
        _left.resize(cur);
        return _left.substr(max(0, (int)_left.size() - 10), 10);
    }

    string cursorRight(int k) {
        int cur = max(0, (int)_right.size() - k);
        string past = _right.substr(cur);
        reverse(past.begin(), past.end());
        _left += past;
        _right.resize(cur);
        return _left.substr(max(0, (int)_left.size() - 10), 10);
    }
private:
    string _left;
    string _right;
};

/**
 * Your TextEditor object will be instantiated and called as such:
 * TextEditor* obj = new TextEditor();
 * obj->addText(text);
 * int param_2 = obj->deleteText(k);
 * string param_3 = obj->cursorLeft(k);
 * string param_4 = obj->cursorRight(k);
 */